package com.mas.framework.common.pojo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author godyao
 * @description 分页结果
 * @date 2023年01月26日20:36
 */
@ApiModel("分页结果")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResult<T> implements Serializable {
    /**
     * 分页数据
     */
    @ApiModelProperty(value = "分页数据", required = true)
    private List<T> data;

    /**
     * 总量
     */
    @ApiModelProperty(value = "数据总量", required = true)
    private Long total;

    public PageResult (Long total) {
        this.data = new ArrayList<>();
        this.total = total;
    }

    public static <T> PageResult<T> empty() {
        return new PageResult<>(0L);
    }

    public static <T> PageResult<T> empty(Long total) {
        return new PageResult<>(total);
    }


}
